﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;


namespace Testing.Cons
{
    public class GestorTXT
    {
        //DECLARACION DE VARIABLES
        int i, j;
        static string path = "C:\\Users\\" + System.Environment.MachineName + "\\Desktop\\Documents\\GedeaDocs\\";
        const string fileName = "Nombre.txt";

        public void Crear(List<string> Lista)
        {
            i = 0;
            j = Lista.Count;

            StreamWriter sr = new StreamWriter(path+fileName);

            while (i < j)
            {
                sr.WriteLine(Lista[i]);
                i++;
            };

            sr.Close();

        }

        public List<string> Leer()
        {
            List<string> res = new List<string>();
            System.IO.StreamReader sr = new System.IO.StreamReader(path + fileName);
            string rrr = sr.ReadToEnd();
            res = Regex.Split(rrr, "\n").ToList();
            res.RemoveAt(res.Count - 1);
            sr.Close();
            
            //TODO: hacer magia y llenar mi lista con los valores del txt

            return res;
        }
    }
}
